package com.example.rbacmanage.service.app;

import com.example.rbacmanage.entity.app.Comment;
import com.example.rbacmanage.mapper.app.CommentMapper;
import com.example.rbacmanage.service.CommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;
    @Override
    public void save(Comment comment) {
        commentMapper.insert(comment);
    }

    @Override
    public void remove(Long[] ids) {
        for (Long id : ids) {
            commentMapper.del(id);
        }
    }

    @Override
    public void update(Comment comment) {
        commentMapper.update(comment);
    }

    @Override
    public List<Comment> getAll(Comment comment) {
        return commentMapper.list(comment);
    }

    @Override
    public PageInfo<Comment> getPage(Comment comment) {
        return new PageInfo<>(getAll(comment));
    }

    @Override
    public Comment getById(Long id) {
        return commentMapper.queryOneById(id);
    }

    @Override
    public Integer getCount(Comment comment) {
        return commentMapper.count(comment);
    }
}
